package com.green.common;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ResponseBodyResultSetUtil {
    public static List<Map<String,Object>> convert(List<? extends Object> list,Converter converter){
    	if(null==list){
    		return null;
    	}
    	final List<Map<String,Object>> resultList=new ArrayList<Map<String,Object>>();
    	for (Object resource : list) {
            final Map<String,Object> targetMap=new HashMap<String, Object>();
            converter.convert(resource, targetMap);
            resultList.add(targetMap);
		}
    	return resultList;
    }
    
    public static interface Converter{
    	void convert(Object resource,Map<String,Object> targetMap);
    }
}
